#
# Process this file with autoconf to produce a configure script.
#
# Copyright (C) 2015 Alexander Andrejevic <theflash AT sdf DOT lonestar DOT org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>
#

AC_PREREQ([2.60])
AC_INIT([XSuperLock], [0.1])
AC_CONFIG_SRCDIR([xsuperlock.c])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE(foreign)
AC_CONFIG_FILES([Makefile xsuperlock.1])

# Checks for programs.
AC_PROG_CC

# Checks for header files.
AC_PATH_X
AC_CHECK_HEADERS([shadow.h stdlib.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_ALLOCA
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset strchr strtok gethostname getspnam])

AC_ARG_VAR(DEFAULT_SCREENSAVER_DIR,
           [A path to the default screensaver directory.])

if test "x$DEFAULT_SCREENSAVER_DIR" == "x"; then
    DEFAULT_SCREENSAVER_DIR='/usr/lib/xscreensaver'
fi

dnl Checks for required libraries
PKG_CHECK_MODULES(X, [x11 >= 1.1 xft >= 2.3])
AC_SUBST([X_CFLAGS])
AC_SUBST([X_LIBS])

PKG_CHECK_MODULES(XF86VM, [xxf86vm >= 1.1.3 xf86vidmodeproto >= 2.3.1])
AC_SUBST([XF86VM_CFLAGS])
AC_SUBST([XF86VM_LIBS])

AC_OUTPUT
